package com.xc.controller.backend;

import com.xc.common.ServerResponse;
import com.xc.pojo.SiteInfo;
import com.xc.service.ISiteBannerService;
import com.xc.service.ISiteInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/3/16 1:44 AM
 */
@Controller
@RequestMapping("/admin/info/")
@Slf4j
public class AdminSiteInfoController {

    @Autowired
    ISiteInfoService iSiteInfoService;

    @Autowired
    ISiteBannerService iSiteBannerService;

    /**
     *  添加设置信息
     * @return
     */
    @RequestMapping("add.do")
    @ResponseBody
    public ServerResponse add(SiteInfo siteInfo){
        return iSiteInfoService.add(siteInfo);
    }

    /**
     *  修改设置信息
     */
    @RequestMapping("update.do")
    @ResponseBody
    public ServerResponse update(SiteInfo siteInfo){
        return iSiteInfoService.update(siteInfo);
    }

    /**
     *  获取设置信息
     * @return
     */
    @RequestMapping("get.do")
    @ResponseBody
    public ServerResponse get(){
        return iSiteInfoService.get();
    }



    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iSiteBannerService.listByAdmin(pageNum,pageSize);
    }







}
